import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { DressResourceApi } from '#/api/wedding/dressresource';

import { z } from '#/adapter/form';
import { 
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

import {formatDressStatus}from '#/utils/wedding'

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'dressCode',
      label: '婚纱编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入婚纱编码',
      },
    },
    {
      fieldName: 'dressName',
      label: '婚纱名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入婚纱名称',
      },
    },
    {
      fieldName: 'style',
      label: '款式编号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入款式编号',
      },
    },
    {
      fieldName: 'size',
      label: '尺码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入尺码',
      },
    },
    {
      fieldName: 'color',
      label: '颜色',
      component: 'Input',
      componentProps: {
        placeholder: '请输入颜色',
      },
    },
    {
      fieldName: 'brand',
      label: '品牌',
      component: 'Input',
      componentProps: {
        placeholder: '请输入品牌',
      },
    },
    {
      fieldName: 'rentalPrice',
      label: '租赁价格(元/天)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入租赁价格(元/天)',
      },
    },
    {
      fieldName: 'inventoryCount',
      label: '库存数量',
      component: 'Input',
      componentProps: {
        placeholder: '请输入库存数量',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      component: 'RadioGroup',
      componentProps: {
        options: [
          { label: '可用', value: 'available' },
          { label: '租赁中', value: 'rented' },
          { label: '维护中', value: 'maintenance' },
          { label: '停用', value: 'disabled' },
        ],
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'dressCode',
      label: '婚纱编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入婚纱编码',
      },
    },
    {
      fieldName: 'dressName',
      label: '婚纱名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入婚纱名称',
      },
    },
    {
      fieldName: 'style',
      label: '款式编号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入款式编号',
      },
    },
    {
      fieldName: 'size',
      label: '尺码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入尺码',
      },
    },
    {
      fieldName: 'color',
      label: '颜色',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入颜色',
      },
    },
    {
      fieldName: 'brand',
      label: '品牌',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入品牌',
      },
    },
    {
      fieldName: 'rentalPrice',
      label: '租赁价格(元/天)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入租赁价格(元/天)',
      },
    },
    {
      fieldName: 'inventoryCount',
      label: '库存数量',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入库存数量',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: formatDressStatus(),
        placeholder: '请选择状态',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<DressResourceApi.DressResource>['columns'] {
  return [
    // {
    //   field: 'id',
    //   title: '主键ID',
    //   minWidth: 120,
    // },
    {
      field: 'dressCode',
      title: '婚纱编码',
      minWidth: 120,
    },
    {
      field: 'dressName',
      title: '婚纱名称',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'images',
      title: '图片预览',
      minWidth: 120,
      slots: { default: 'images' },
    },
    {
      field: 'style',
      title: '款式编号',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'size',
      title: '尺码',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'color',
      title: '颜色',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'brand',
      title: '品牌',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'rentalPrice',
      title: '租赁价格(元/天)',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'inventoryCount',
      title: '库存数量',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
      // cellRender: {
      //   name: 'CellDict',
      //   props: { type: DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase() },
      // },
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

